package top.melody.ecommerce.webapps.www.weblogic;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import top.melody.ecommerce.platform.EcommerceException;
import top.melody.ecommerce.platform.api.domain.account.AccountEnterpriseAuth;
import top.melody.ecommerce.platform.api.service.AccountAuthService;
import top.melody.ecommerce.platform.api.service.AccountService;

import javax.annotation.Resource;

/**
 * @author: blentle
 * @group: rd
 * @createdate: 2016/11/16 14:51
 * @mail: blentle.huan.ren@gmail.com
 * @description:
 * @since:1.0
 */
@Service
public class AuthenticationWeblogic {

    private final static Logger logger = LoggerFactory.getLogger(AuthenticationWeblogic.class);
    @Resource
    private AccountService accountService;
    @Resource
    private AccountAuthService authService;

    public boolean isExistsEnterprise(String enterpriseName) throws EcommerceException {
        AccountEnterpriseAuth queryEntity = new AccountEnterpriseAuth();
        queryEntity.setEnterpriseName(enterpriseName);
        return authService.getAccountEnterpriseAuthCount(queryEntity) > 0;
    }

    public AccountEnterpriseAuth createAuthentication(AccountEnterpriseAuth enterprise) throws EcommerceException {
        return authService.createAuthentication(enterprise);
    }
}
